import { defineConfig, presetUno } from 'unocss'
export default defineConfig({
  /* 排除 */
  exclude: ['node_modules'],

  /* 预设 */
  presets: [presetUno()],

  /* 自定义规则 */
  rules: [
    /* margin 外边距 */
    [/^ma-(.+)-(.+)$/, ([, a, b]) => ({ margin: `${a} ${b}` })],
    [/^mx-(.+)-(.+)$/, ([, a, b]) => ({ 'margin-left': `${a}`, 'margin-right': `${b}` })],
    [/^my-(.+)-(.+)$/, ([, a, b]) => ({ 'margin-top': `${a}`, 'margin-bottom': `${b}` })],
    [/^mt-(.+)$/, ([, a]) => ({ 'margin-top': `${a}` })],
    [/^mr-(.+)$/, ([, a]) => ({ 'margin-right': `${a}` })],
    [/^mb-(.+)$/, ([, a]) => ({ 'margin-bottom': `${a}` })],
    [/^ml-(.+)$/, ([, a]) => ({ 'margin-left': `${a}` })],

    /* padding 内边距 */
    [/^pa-(.+)-(.+)$/, ([, a, b]) => ({ padding: `${a} ${b}` })],
    [/^px-(.+)-(.+)$/, ([, a, b]) => ({ 'padding-left': `${a}`, 'padding-right': `${b}` })],
    [/^py-(.+)-(.+)$/, ([, a, b]) => ({ 'padding-top': `${a}`, 'padding-bottom': `${b}` })],
    [/^pt-(.+)$/, ([, a]) => ({ 'padding-top': `${a}` })],
    [/^pr-(.+)$/, ([, a]) => ({ 'padding-right': `${a}` })],
    [/^pb-(.+)$/, ([, a]) => ({ 'padding-bottom': `${a}` })],
    [/^pl-(.+)$/, ([, a]) => ({ 'padding-left': `${a}` })],

    /* 边框 */
    [/^br-(.+)-(.+)-(.+)$/, ([, a, b, c]) => ({ border: `${a} ${b} ${c}` })],
    [/^br-t-(.+)-(.+)-(.+)$/, ([, a, b, c]) => ({ 'border-top': `${a} ${b} ${c}` })],
    [/^br-r-(.+)-(.+)-(.+)$/, ([, a, b, c]) => ({ 'border-right': `${a} ${b} ${c}` })],
    [/^br-b-(.+)-(.+)-(.+)$/, ([, a, b, c]) => ({ 'border-bottom': `${a} ${b} ${c}` })],
    [/^br-l-(.+)-(.+)-(.+)$/, ([, a, b, c]) => ({ 'border-left': `${a} ${b} ${c}` })],
    [/^brr-(.+)$/, ([, a]) => ({ 'border-radius': `${a}` })],
    [/^brrs-(.+)-(.+)-(.+)-(.+)$/, ([, a, b, c, d]) => ({ 'border-radius': `${a} ${b} ${c} ${d}` })],

    /* font 字体 */
    [/^fs-(.+)$/, ([, a]) => ({ 'font-size': `${a}` })],
    [/^fw-(.+)$/, ([, a]) => ({ 'font-weight': `${a}` })],
    [/^fm-(.+)$/, ([, a]) => ({ 'font-family': `${a}` })],
    [/^line-hight-(.+)$/, ([, a]) => ({ 'line-height': `${a}` })],
    [/^lsp-(.+)$/, ([, a]) => ({ 'letter-spacing': `${a}` })],

    /* 文本超出 1行显示... */
    [/^yy-1-hidden$/, ([]) => ({ 'white-space': 'nowrap', overflow: 'hidden', 'text-overflow': 'ellipsis' })],
    /* 文本超出 n行显示... */
    [
      /^yy-n-hidden-(.+)$/,
      ([, a]) => ({ display: '-webkit-box', '-webkit-box-orient': 'vertical', '-webkit-line-clamp': `${a}`, overflow: 'hidden' }),
    ],

    /* 背景色 */
    [/^bac-(.+)$/, ([, a]) => ({ 'background-color': `${a}` })],

    /* flex布局 */
    [/^yy-flex-start$/, ([]) => ({ display: 'flex', 'justify-content': 'flex-start', 'align-items': 'center' })],
    [/^yy-flex-center$/, ([]) => ({ display: 'flex', 'justify-content': 'center', 'align-items': 'center' })],
    [/^yy-flex-end$/, ([]) => ({ display: 'flex', 'justify-content': 'flex-end', 'align-items': 'center' })],
    [/^yy-flex-sp$/, ([]) => ({ display: 'flex', 'justify-content': 'space-between', 'align-items': 'center' })],
    [/^yy-flex-column$/, ([]) => ({ display: 'flex', 'flex-direction': 'column', 'align-items': 'center' })],
  ],

  /* 自定义快捷方式 */
  shortcuts: {},
})
